package io.bdmc.modules.bss.controller;

import io.bdmc.common.annotation.SysLogger;
import io.bdmc.common.utils.R;
import io.bdmc.modules.bss.entity.FibreView;
import io.bdmc.modules.bss.service.IDeviceFibreMatchService;
import io.bdmc.modules.bss.service.IFibreViewService;
import io.bdmc.modules.sys.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

//import org.apache.shiro.authz.annotation.RequiresPermissions;

/**
 * <p>
 * 光缆视图 前端控制器
 * </p>
 *
 * @author 黄露
 * @since 2021-05-21
 */

// "光缆视图", description = "光缆视图")
@RestController
@RequestMapping("/bss/view")
public class FibreViewController extends AbstractController {

	@Autowired
	IFibreViewService viewService;
	

	@Autowired
	IDeviceFibreMatchService matchService;



	@SysLogger("新增光缆视图")
	@PostMapping("/add")
	public R add(@RequestBody FibreView fibreView) {
		fibreView.setCreateBy(getUser().getUsername());
		fibreView.setCreateTime(LocalDateTime.now());
		Boolean b = fibreView.insert();
		return R.trueOrFalse(b);
	}


	@GetMapping("/info")
	public R list(int viewId) {
		return R.ok().putData(viewService.getById(viewId));
	}

	@SysLogger("修改光缆视图")
	@PostMapping("/update")
	public R update(@RequestBody FibreView fibreView) {

		Boolean b = fibreView.updateById();
		return R.trueOrFalse(b);
	}

	@SysLogger("删除光缆视图")
	@PostMapping("/delete")
	public R delete(@RequestBody Integer viewId) {
		return R.trueOrFalse(viewService.removeById(viewId));
	}
}
